package com.nmgydy.beans;

import com.alibaba.fastjson.JSON;

public class ResultCodeBean{

	private boolean res;
	private String msg;
	private String code;
	private Object data;
	
	private ResultCodeBean() {
		this.res = true;
		this.msg = "";
	}
	private ResultCodeBean(boolean res, String msg,Object data) {
		this.res = res;
		this.msg = msg;
		this.data = data;
	}
	
	public boolean getRes() {
		return res;
	}
	public void setRes(boolean res) {
		this.res = res;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	public static ResultCodeBean success(Object data) {
		ResultCodeBean resultBean = new ResultCodeBean(true,"success",data);
		return resultBean;
	}
	
	public static ResultCodeBean success(String msg,Object data) {
		ResultCodeBean resultBean = new ResultCodeBean(true,msg,data);
		return resultBean;
	}
	
	public static ResultCodeBean failure() {
		ResultCodeBean resultBean = new ResultCodeBean(false,"failure",null);
		return resultBean;
	}
	
	public static ResultCodeBean failure(String msg) {
		ResultCodeBean resultBean = new ResultCodeBean(false,msg,null);
		return resultBean;
	}
	
	public static ResultCodeBean failure(String code,String msg) {
		ResultCodeBean resultBean = new ResultCodeBean(false,msg,null);
		resultBean.setCode(code);
		return resultBean;
	}

	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}

}
